Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
$(document).ready(function(){
	var rootPath = getRootPath();
	
	$.ajax({
		headers: {'Cookie' : document.cookie },
		method : 'get',
		url : rootPath+'/customer/api/v1/memberInfo',
		dataType:"json", 
		async: false,
		contentType:"application/json",               
		data:null, 
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			//alert("未连接服务器!");
		},
		success : function(resultData){
			$.each(resultData,function(maintainSelIndex,maintainSelObj){
				$.ajax({
					method : 'get',
					url : rootPath+'/points/api/v1/ttcustomerpoint?userId='+maintainSelObj.userId+'',
					error:function(XMLHttpRequest, ajaxOptions, thrownError){
						//alert("连接服务器错误!");
					},
					success : function(resultData){
						var wholeHtml = '';
						$.each(resultData,function(maintainIndex,customerpointsdto){
							//var curDate = new Date();
							var curDate = new Date(customerpointsdto.registerDate);
							//alert(curDate);
							var newDate=new Date(curDate.setFullYear(curDate.getFullYear()+2));
							//alert(newDate);
							var date = newDate.Format("yyyy-MM-dd");
							var remark=customerpointsdto.remark;
							if(customerpointsdto.changePoints>0){var changepoints="+"+customerpointsdto.changePoints;}
							else if(customerpointsdto.changePoints<0){var changepoints=customerpointsdto.changePoints;}
							else{var changepoints=customerpointsdto.changePoints;}
							var createDate=customerpointsdto.createDate;
							var pointHtml='';
							var td_0 = '<td class="change" style="width:160px;text-align:right;color:red;">'+changepoints+'</td>';
							var td_10 = '<td class="change" style="width:160px;text-align:right;color:blue;">'+changepoints+'</td>';
							var rst = changepoints>0?td_0:td_10;
							pointHtml=pointHtml+'<div style="background-color: #FFFFFF; border-bottom: 1px solid #e5e5e5; padding: 6px 10px 3px 10px;">'
							                   +'<table style="width:100%" class="table-condensed"><tbody>'
							                   +'<tr>'
							                   +'<td style="width:160px;text-align:left;font-size: 14px;">'+remark+'</td>'
							                   + rst
							                   +'</tr>'
							                   +'<tr>'
							                   +'<td  style="font-family:宋体;text-align:left;font-size:12px;color:#7a7a7a">'+createDate+'</td>'
							                   +'<td class="" style="width:160px;text-align:right;font-size:12px;color:#7a7a7a">有效期:'+date+'</td>'
							                   +'</tr>'
							                   +'</tbody>'
							                   +'</table>'
							                   +'</div>'
						 wholeHtml += pointHtml;
						});
						$("#point").append(wholeHtml);
					}
				});
			});
		}
	});

	
	
})
